package com.bkgy.controller.outputRecord.controller;

import com.bkgy.controller.outputRecord.entity.pdo.WorkBreakReq;
import com.bkgy.controller.outputRecord.entity.pdo.WorkBreakRes;
import com.bkgy.controller.outputRecord.service.IOutputRecordService;
import com.bkgy.sys.common.entity.ResultData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;

@Tag(name = "产量系列报表", description = "产量报表统计图")
@Controller
@RequestMapping("/tpdol3")
@RequiredArgsConstructor
public class OutputRecordController {
    private final IOutputRecordService service;

    @Operation(summary = "作业区总览/产量破记录")
    @PostMapping("/workBreak")
    @ResponseBody
    public ResultData<WorkBreakRes> workBreak(@RequestBody @Valid WorkBreakReq req) {
        return service.workBreak(req);
    }

    @Operation(summary = "【作业区总览/构建产量破记录】")
    @PostMapping("/buildWorkBreak")
    @ResponseBody
    public ResultData<String> buildWorkBreak(String dateType) {
        if ("daily".equals(dateType) || "monthly".equals(dateType) || "day".equals(dateType) || "night".equals(dateType)) {
            return service.buildOutputRecord(dateType);
        }
        return ResultData.ResultDataFaultSelf("构建失败", null);
    }
}
